package com.mall.cms.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.cms.service.SubjectService;
import com.mall.model.domain.cms.Subject;
import com.mall.utils.PageResult;
import com.mall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @GetMapping("/list")
    public R<PageResult> subject(String keyword, Integer pageNum, Integer pageSize){
        PageResult page = subjectService.getSubject(keyword,pageNum,pageSize);
        return R.success(page);
    }

    @GetMapping("/listAll")
    public R<List> listAll(){
        List<Subject> subjectList = subjectService.list(null);
        return R.success(subjectList);
    }
}
